import { useParams, useSearchParams } from "react-router-dom"

const Article = () => {
    // searchParams传参方式接收参数
    const [searchParams] = useSearchParams()
    const id1 = searchParams.get('id')
    const name1 = searchParams.get('name')

    // params传参方式接收参数
    const params = useParams()
    const id2 = params.id
    const name2 = params.name

    return (
        <div>
            <p>我是文章</p>
            {id1 && <p>searchParams传参接收到的参数：{id1}-{name1}</p>}
            {id2 && <p>params传参接收到的参数：{id2}-{name2}</p>}
        </div>
    )
}

export default Article